<?php
/**
 * Created by PhpStorm.
 * User: HJJ
 * Date: 2022-11-10
 * Time: 10:22:35
 * Info:
 */

namespace app\api\controller;
use app\common\model\tabar as tabarModel;
use app\common\model\banner as bannerModel;
use app\common\model\bannerType as bannerTypeModel;
use app\common\model\notice as noticeModel;
use app\common\model\article as articleModel;

use think\facade\Db;

class UserController extends BaseController
{
    // 首页数据
    public function index()
    {
        $tabList = tabarModel::order('sort_order asc, id desc')->select(); // 栏目
        $tid = bannerTypeModel::where('name', '首页轮播图')->value('tid');
        $swiperList = bannerModel::order('listorder asc, id desc')->limit(5)->where('typeid', $tid)->select(); // 轮播图
        $noticeList = noticeModel::order('sorts asc, id desc')->limit(5)->select(); // 栏目
        $recentPolicyList = articleModel::order('create_time desc, weight asc, id desc')->limit(3)->select(); // 近期政策
        $data = array(
          'wx_name' => get_config('wx_name'),
          'wx_logo' => get_config('wx_logo'),
          'tabList' => $tabList,
          'swiperList' => $swiperList,
          'noticeList' => $noticeList,
          'recentPolicyList' => $recentPolicyList,
        );
        $this->success(200, $data);
    }

}